package com.mooc.ppjoke.ui.detail;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.mooc.ppjoke.data.Feed;

/**
 * @ClassName: FeedDetailActivity$
 * @Description: java类作用描述
 * @Author: 魏靳元
 * @CreateDate: 2022/8/25 08:08
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
public class FeedDetailActivity extends AppCompatActivity {
    public static final String KEY_FEED="key_feed";
    public static final String KEY_CATEGORY="key_category";
    @Override
    protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Feed feed = (Feed) getIntent().getSerializableExtra(KEY_FEED);
        if(feed==null){
            finish();
            return;
        }
        ViewHandler viewHandler=null;
        if(feed.itemType==Feed.TYPE_IMAGE){
            viewHandler = new ImageViewHandler(this);
        }else {
            viewHandler = new VideoViewHandler(this);
        }

        viewHandler.bindInitData(feed);
    }
    public static void startFeedDetailActivity(Context context, Feed item, String category) {
        Intent intent = new Intent(context, FeedDetailActivity.class);
        intent.putExtra(KEY_FEED, item);
        intent.putExtra(KEY_CATEGORY, category);
        context.startActivity(intent);
    }

}
